/**
 * popup.css - Popup 窗口样式表
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    width: 900px;
    max-height: 700px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #2d2d2d;
}

/* 导航栏 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #252526;
    color: white;
    border-bottom: 1px solid #3e3e42;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nav-buttons {
    display: flex;
    gap: 0;
    background: #1e1e1e;
    border-radius: 4px;
    overflow: hidden;
}

.nav-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-right: 1px solid #3e3e42;
}

.nav-btn:last-child {
    border-right: none;
}

.nav-btn:hover {
    background: #37373d;
    color: white;
}

.nav-btn.active {
    background: #667eea;
    color: white;
    border-right-color: #667eea;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    display: inline-block;
    padding: 4px 12px;
    background: #37373d;
    color: #ccc;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.active {
    background: #10b981;
    color: white;
}

.status-indicator.error {
    background: #ef4444;
    color: white;
}

/* 内容区域 */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #2d2d2d;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 部分标题 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #3e3e42;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #e0e0e0;
}

.stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #999;
}

.stats span {
    padding: 4px 8px;
    background: #1e1e1e;
    border-radius: 4px;
    color: #ccc;
}

/* 按钮 */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 9px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-primary:active {
    background: #4a5bc4;
}

.btn-secondary {
    background: #37373d;
    color: #e0e0e0;
    border: 1px solid #4e4e53;
}

.btn-secondary:hover {
    background: #4a4a4f;
    border-color: #5f5f64;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    color: #999;
}

.close-btn:hover {
    color: #e0e0e0;
}

/* 规则列表 */
.rules-list {
    display: grid;
    gap: 0;
    margin: 0 auto;
    overflow-y: auto;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
}

.rule-item {
    min-height: 100px;
    background: #1e1e1e;
    border: none;
    border-bottom: 1px solid #3e3e42;
    padding: 12px;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.rule-item:last-child {
    border-bottom: none;
}

.rule-item:hover {
    background: #252526;
    box-shadow: none;
    border-color: #3e3e42;
    transform: none;
}

.rule-info {
    flex: 1;
    min-width: 0;
    align-items: center;
    width: 100%;
}

.rule-name {
    margin-bottom: 4px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rule-name::before {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    display: inline-block;
}

.rule-details {
    font-size: 12px;
    color: #999;
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 8px 16px;
    align-items: center;
    width: 100%;
}

.rule-detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 200px;
    flex-wrap: wrap;
}

.rule-detail-row-url {
  width: 340px;;
}

.rule-detail-label {
    font-weight: 500;
    color: #666;
    display: inline-block;
    font-size: 11px;
}

.rule-detail-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
}

.rule-actions {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
    margin-left: 16px;
    flex-shrink: 0;
    align-items: center;
}

.rule-actions svg {
    height: 16px;
    width: 16px;
}

.rule-actions button {
    height: 32px;
    width: 32px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #37373d;
    color: #e0e0e0;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.rule-toggle {
    position: absolute;
    right: 12px;
    top: 12px;
}

.rule-actions button:hover {
    background: #4a4a4f;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.rule-actions button[data-action="toggle"] {
    color: white;
}

.rule-actions button[data-action="toggle"]:hover {
    background: #059669;
}

.rule-actions button[data-action="delete"] {
    color: white;
}

.rule-actions button[data-action="delete"]:hover {
    background: #dc2626;
}

.rule-actions button[data-action="edit"] {
    color: white;
}

.rule-actions button[data-action="edit"]:hover {
    background: #5568d3;
}

.rule-actions button[data-action="duplicate"] {
    color: white;
}

.rule-actions button[data-action="duplicate"]:hover {
    background: #d97706;
}

.toggle-switch {
    width: 40px;
    height: 20px;
    border-radius: 12px;
    background: #37373d;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    outline: none;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #666;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle-switch.enabled {
    background: #10b981;
}

.toggle-switch.enabled::after {
    left: 18px;
    background: white;
}

.toggle-switch:hover {
    transform: scale(1.05);
}

/* 图标按钮样式 */
.icon-btn {
    width: 36px;
    height: 36px;
    padding: 8px;
    background: #37373d;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.icon-btn:hover {
    background: #4a4a4f;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.icon-btn[data-action="edit"] {
    color: white;
}

.icon-btn[data-action="edit"]:hover {
    background: #5568d3;
}

.icon-btn[data-action="duplicate"] {
    color: white;
}

.icon-btn[data-action="duplicate"]:hover {
    background: #d97706;
}

.icon-btn[data-action="delete"] {
    color: white;
}

.icon-btn[data-action="delete"]:hover {
    background: #dc2626;
}

/* 编辑面板 */
.editor-panel {
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    margin-bottom: 16px;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #252526;
    border-bottom: 1px solid #3e3e42;
}

.editor-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
}

.editor-content {
    padding: 16px;
    overflow-y: auto;
    background: #1e1e1e;
    color: #e0e0e0;
}

.editor-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #3e3e42;
}

.editor-buttons .btn {
    flex: 1;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #ccc;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.3s;
    font-family: inherit;
    background: #252526;
    color: #e0e0e0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #999;
    font-size: 12px;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'Monaco', 'Courier New', monospace;
    background: #252526;
    color: #e0e0e0;
}

/* 复选框 */
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 12px;
    font-weight: 500;
    color: #ccc;
}

.checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

/* 开关组 */
.toggle-group {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 500;
    color: #ccc;
}

.toggle-label {
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

/* 部分 */
.section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #3e3e42;
}

.section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* 键值列表 */
.key-value-list {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}

.key-value-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.header-type-select {
    width: 200px !important;
}

.key-value-item input {
    padding: 6px 8px;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    font-size: 12px;
    background: #252526;
    color: #e0e0e0;
}

.key-value-item input:first-child {
   width: 200px;
}

.key-value-item button {
    width: 100px;
    padding: 6px 8px;
    background: #37373d;
    border: 1px solid #4a4a4f;
    color: #ef4444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.key-value-item button:hover {
    background: #4a4a4f;
    border-color: #5f5f64;
}

/* Cookie 列表 */
.cookies-list {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    gap: 6px;
}

.cookie-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e1e1e;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #3e3e42;
    font-size: 12px;
    color: #e0e0e0;
}

.cookie-name {
    font-weight: 500;
    color: #ccc;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cookie-value {
    color: #999;
    margin: 0 8px;
    flex: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Monaco', 'Courier New', monospace;
}

.cookie-item button {
    padding: 4px 8px;
    background: #37373d;
    border: 1px solid #4a4a4f;
    color: #ef4444;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s;
}

.cookie-item button:hover {
    background: #4a4a4f;
    border-color: #5f5f64;
}

.hint {
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 16px;
    margin: 0;
    background: #1e1e1e;
    border: 1px dashed #3e3e42;
    border-radius: 4px;
}

.cookie-section {
    margin-bottom: 16px;
}

.cookie-section h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
}

/* 日志列表 */
.logs-list {
    display: grid;
    gap: 0;
    max-height: 400px;
    overflow-y: auto;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    overflow: hidden;
}

.log-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #252526;
    border-bottom: 1px solid #3e3e42;
}

/* 日志表头 */
.logs-header {
    display: grid;
    grid-template-columns: 120px 120px 80px 1fr;
    gap: 12px;
    padding: 12px 18px;
    background: #252526;
    color: #ccc;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid #3e3e42;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.log-item {
    background: #1e1e1e;
    border: none;
    border-bottom: 1px solid #3e3e42;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: grid;
    grid-template-columns: 120px 120px 80px 1fr;
    gap: 12px;
    align-items: center;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item:hover {
    background: #252526;
    box-shadow: none;
    transform: none;
}

.log-item.response {
    background: #1e1e1e;
}

.log-item.error {
    background: #251e1e;
}

.log-time {
    font-size: 12px;
    color: #999;
    font-family: 'Monaco', 'Courier New', monospace;
}

.log-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
}

.log-status.ok {
    background: #10b981;
    color: white;
}

.log-status.error {
    background: #ef4444;
    color: white;
}

.log-status.warning {
    background: #f59e0b;
    color: white;
}

.log-status.404 {
    background: #ef4444;
    color: white;
}

.log-method {
    display: inline-block;
    padding: 4px 8px;
    background: #667eea;
    color: white;
    border-radius: 3px;
    font-weight: 600;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    text-align: center;
    min-width: 60px;
}

.log-url {
    font-size: 12px;
    color: #e0e0e0;
    font-family: 'Monaco', 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-header {
    display: none;
}

.log-type {
    display: none;
}

.log-meta {
    display: none;
}

/* 日志详情内容 */
#log-detail-content {
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    padding: 16px;
    max-height: 500px;
    overflow-y: auto;
    font-size: 12px;
    color: #e0e0e0;
}

/* 日志详情分区 */
.log-detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #3e3e42;
}

.log-detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.log-detail-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.log-detail-section > div {
    margin-bottom: 8px;
    line-height: 1.6;
}

.log-detail-section strong {
    color: #ccc;
    min-width: 80px;
    display: inline-block;
}

/* 方法徽章 */
.method-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #667eea;
    color: white;
    border-radius: 3px;
    font-weight: 500;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* 状态徽章 */
.status-success {
    color: #10b981;
    font-weight: 500;
}

.status-error {
    color: #ef4444;
    font-weight: 500;
}

/* 代码 */
code {
    background: #37373d;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    word-break: break-all;
    color: #e0e0e0;
}

/* 请求头/响应头 */
.log-headers {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 3px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.header-item {
    padding: 6px 8px;
    border-bottom: 1px solid #3e3e42;
    font-size: 11px;
    line-height: 1.6;
    color: #ccc;
}

.header-item:last-child {
    border-bottom: none;
}

/* 请求体/响应体 */
.log-body {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 3px;
    padding: 12px;
    margin: 8px 0;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.5;
    word-break: break-all;
    white-space: pre-wrap;
    color: #e0e0e0;
}

/* 错误文本 */
.error-text {
    color: #ef4444;
    background: #251e1e;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #4a2c2c;
}

/* 设置 */
.settings-group {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #3e3e42;
}

.settings-group .btn {
    margin-top: 12px;
}

.settings-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 12px;
}

.settings-group p {
    font-size: 13px;
    color: #999;
    margin-bottom: 8px;
}

/* 搜索和过滤 */
#search-logs {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    font-size: 13px;
    background: #1e1e1e;
    color: #e0e0e0;
}

#search-logs:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

#filter-type, #filter-matched {
    padding: 9px 14px;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    font-size: 13px;
    background: #1e1e1e;
    color: #e0e0e0;
    cursor: pointer;
}

#filter-type:focus, #filter-matched:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .rule-details {
        grid-template-columns: 1fr;
    }

    .key-value-item {
        grid-template-columns: 1fr;
    }
}

/* 加载状态 */
.loading {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    background: #1e1e1e;
    border: 1px dashed #3e3e42;
    border-radius: 4px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: #666;
}

.empty-state-text {
    font-size: 14px;
    margin-bottom: 16px;
    color: #999;
}
